package designpattern.observer;

/**
 * TODO:类描述
 *
 * @className: TestObserver
 * @packageName: designpattern.observer
 * @author: Zhuhj
 * @version: V1.0
 * @date: 2021/4/18 22:19
 */
public class TestObserver {
    public static void main(String[] args) {
        Teacher teacher = new Teacher();
        Student zhangsan = new Student("zhangsan");
        Student lisi = new Student("lisi");
        Student wangwu = new Student("wangwu");

        teacher.regObserver(zhangsan);
        teacher.regObserver(lisi);
        teacher.regObserver(wangwu);

        teacher.setPhone("111");

        System.out.println(zhangsan.getTphnoe());
        System.out.println(lisi.getTphnoe());
        System.out.println(wangwu.getTphnoe());

        teacher.removerObserver(zhangsan);
        teacher.setPhone("222");

        System.out.println(zhangsan.getTphnoe());
        System.out.println(lisi.getTphnoe());
        System.out.println(wangwu.getTphnoe());


    }
}
